
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/layer.css">
    <link rel="stylesheet" type="text/css" href="css/swiper.min.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script src="js/layer.js"></script>
    <script src="js/swiper.min.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
</head>
<body>
  <div class="nav"></div>
  <div class="user-center top125">
  	<div class="user-info">
  		<a href="set_password.html" class="user-into-set">
  			<div class="user-img"></div>
  			<div class="user-name"></div>
  		</a>
  		<a class="user-money" href="record.html">
  			<span>余额</span>
  			<span class="user-money-span">00.00</span>
  			<span></span>
  		</a>

  	</div>
  	<!-- 已购买的电影 -->
  	<!-- 视频列表 -->
    <div class="list list-1">
        <div class="list-type clearfix">
          <div class="list-title">已购买电影</div>
          <a href="movieist.html?id=purchasedList" class="list-clone">更多 <span></span></a>
        </div>
        <ul>
        </ul>
    </div>
    <div class="list list-2">
        <div class="list-type clearfix">
          <div class="list-title">观看历史</div>
          <a href="movieist.html?id=historyList" class="list-clone">更多 <span></span></a>
        </div>
        <ul>
        </ul>
    </div>
  </div>
  <div class="search-box searchide"></div>
</body>
<script type="text/javascript">
  $(function(){
    var id = $.cookie("id");
    var token = $.cookie('token_access');
    if(token != undefined){
        $.ajax({
          url: window.baseUrl+'api/user/info',
          type: 'get',
          beforeSend: function (XMLHttpRequest) {
            XMLHttpRequest.setRequestHeader("token", token);
          },
          success: function (data) {
              if(data.code == '200'){
                  // 个人中心列表
                $(".user-name").html(data.datas.customer.username);
                $(".user-money-span").html(data.datas.customer.balance+'元')
                var indexList = data.datas.purchasedMovie;
                var listStr = '';
                if(indexList.length == 0){
                    $(".list-1 ul").html('<img src="images/kong1@2x.png" class="no-data">')
                    $(".list-1 .list-clone").hide();
                }else{
                    for(var i = 0;i<indexList.length;i++){
                        if(indexList[i].tag == ''){
                            var setTag = ''
                        }else{
                            var setTag = '<div class="hot"><span>'+indexList[i].tag+'</span></div>'
                        }
                        listStr = listStr+'<li><div class="piclist-img">'+
                          '<a href="detail.html?id='+indexList[i].id+'" >'+
                          '<img src="'+indexList[i].logo+'" alt="">'+
                          '<div class="definition">'+indexList[i].clarity+'</div>'+setTag+
                          ' </a></div><div class="piclist-title">'+indexList[i].movieName+'</div></li></div>';
                    }
                    $(".list-1").find("ul").html(listStr)
                }
                var viewList = data.datas.viewMovie;
                var viewStr = '';
                if(viewList.length == 0){
                    $(".list-2 ul").html('<img src="images/kong2@2x.png" class="no-data-2">')
                    $(".list-2 .list-clone").hide();
                }else{
                  for(var i = 0;i<viewList.length;i++){
                      if(viewList[i].tag == ''){
                          var setTag = ''
                      }else{
                          var setTag ='<div class="hot"><span>'+viewList[i].tag+'</span></div>'
                      }
                      viewStr = viewStr+'<li><div class="piclist-img">'+
                        '<a href="detail.html?id='+viewList[i].id+'" >'+
                        '<img src="'+viewList[i].logo+'" alt="">'+
                        '<div class="definition">'+viewList[i].clarity+'</div>'+setTag+
                        '</a></div><div class="piclist-title">'+viewList[i].movieName+'</div></li></div>';
                  }
                  $(".list-2").find("ul").html(viewStr)
                }
              }else{
                window.location.href="login.html";
              }
          }
        });
    }else{
      window.location.href="login.html";
    }
    
  })
</script>
</html>